package com.example.snackfood.controller;

import com.example.snackfood.entity.Carts;
import com.example.snackfood.entity.Orders;
import com.example.snackfood.services.IsnackFoodOrdersService;
import com.example.snackfood.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: snackFood
 * @description:
 * @author: lydms
 * @create: 2023-11-24 22:52
 **/


@RestController
@RequestMapping("/Orders")
public class SnackFoodOrdersController {


    @Autowired
    private IsnackFoodOrdersService isnackFoodOrdersService;
    //增：Carts
    @PostMapping("/saveOrders")
    public R save(@RequestBody Orders orders) {
        isnackFoodOrdersService.saveOrders(orders);
        return R.success("增加成功");
    }
    //删：
    @DeleteMapping("/deleteOrders/{id}")
    public R delete(@PathVariable Long id){
        isnackFoodOrdersService.deleteOrders(id);
        return R.success("成功删除");
    }

    //改：
    @PutMapping("/updateOrders")
    public R update(@RequestBody Orders orders){
        isnackFoodOrdersService.updateOrders(orders);
        return R.success(orders);
    }

    //查（条件查询）：
    @GetMapping("/getOrders")
    public Orders getOrders(@RequestBody Orders orders){return isnackFoodOrdersService.getOrders(orders);}
}
